import React from 'react';
import { Link } from 'umi';
import { Row } from 'antd';

import { useRequest } from '@/hooks';
import { SEX } from '@/pages/Recruitment/dictionary';
import { getDict } from '@/utils/dataDictUtil';
import { EmptyText } from '@/components';

import { renderItem, getDictName } from '../util';

export default function Talent({ talentInfo = {}, applyData = {}, recordInfo = {} }) {
    const { data: AGREE_TYPE } = useRequest(() => getDict('agreeType'), { initialData: [] });
    return (
        <>
            <Row>
                {renderItem({
                    label: '姓名',
                    value: <EmptyText>{talentInfo.talentName}</EmptyText>
                })}
                {renderItem({ label: '性别', value: <EmptyText>{getDictName(talentInfo.talentSex, SEX)}</EmptyText> })}
            </Row>
            <Row>
                {renderItem({ label: '出生年月', value: <EmptyText>{talentInfo.talentBirth}</EmptyText> })}
                {renderItem({
                    label: '最高学历',
                    value: <EmptyText>{getDictName(talentInfo.talentDegree, AGREE_TYPE || [])}</EmptyText>
                })}
            </Row>
            <Row>
                {renderItem({
                    label: '国籍/籍贯',
                    value: <EmptyText>{talentInfo?.talentNativePlace?.split(',').join('/')}</EmptyText>
                })}
                {renderItem({
                    label: '工作经历',
                    value: <EmptyText>{`${talentInfo.talentWorkYearNum ?? ''}年`}</EmptyText>
                })}
            </Row>
            <Row>
                {renderItem({ label: '应聘部门', value: <EmptyText>{talentInfo.organizationName}</EmptyText> })}
                {renderItem({ label: '应聘岗位', value: <EmptyText>{talentInfo.dutyName}</EmptyText> })}
            </Row>
            <Row>
                {renderItem({ label: '应聘时间', value: <EmptyText>{recordInfo.acceptDate}</EmptyText> })}
                {renderItem({ label: '招聘负责人', value: <EmptyText>{recordInfo.principalEmployeeName}</EmptyText> })}
            </Row>
            <Row>
                {renderItem({
                    label: '应聘简历',
                    value: (
                        <Link
                            to={{
                                pathname: '/office/personnelManagement/recruitment/resume/detail',
                                query: {
                                    activeKey: 'RESUME',
                                    id: talentInfo.recruitTalentMatcherId,
                                    candidateId: applyData.candidateId,
                                    employId: applyData.employId
                                }
                            }}
                        >
                            查看简历详情
                        </Link>
                    )
                })}
                {renderItem({ label: '所属行政机构', value: <EmptyText>{talentInfo.companyName}</EmptyText> })}
            </Row>
            <Row>
                {renderItem({
                    label: '背调',
                    value: talentInfo.backgroundCheckFlag ? (
                        <Link
                            to={{
                                pathname: '/office/personnelManagement/recruitment/hire/backgroundRec',
                                query: {
                                    candidateId: applyData?.candidateId,
                                    employId: applyData?.employId
                                }
                            }}
                        >
                            查看详情
                        </Link>
                    ) : (
                        '-'
                    )
                })}
            </Row>
        </>
    );
}
